LONG WINAPI MainWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	LONG lRet = 0;
	Window* win = Window::Window();

	switch(uMsg)
	{
	case WM_CREATE:
		cl_hwnd = hWnd;
		break;
	case WM_PAINT:
		win->update_screen();
		break;
	case WM_DESTROY:
		cl_hwnd = NULL;
		break;
	case WM_MOVE:
		{
			int x_pos, y_pos;
			RECT rect;
			int style;

			if(!win->fullscreen)
		}
		// Mouse events
	case WM_LBUTTONDOWN:
	case WM_RBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_RBUTTONUP:
	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:
	case WM_MOUSEMOVE:
		{
			int f;
			f = 0;

			if ( wParam & MK_LBUTTON )
				f |= 1;

			if ( wParam & MK_RBUTTON )
				f |= 2;

			if ( wParam & MK_MBUTTON )
				f |= 4;

			win->mouse_event( f );
		}
		break;

	case WM_SYSKEYDOWN:
		if ( wParam == 13 )
		{
			if ( window->is_fullscreen() )
			{
				cvar->set_value( "vid_fullscreen", !win->is_fullscreen() );
			}
			return 0;
		}
	case WM_KEYDOWN:
		win->key_event( win->map_key( lParam ), true, sys_msg_time );
		break;

	case WM_SYSKEYUP:
	case WM_KEYUP:
		key_event( map_key( lParam ), false, sys_msg_time );
		break;

	default:
		return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
}

